import {Injectable} from "@angular/core";
import {PageService} from "@core/service/page/PageService";
import {DiskService} from "@core/service/DiskService";
import {NzMessageService} from "ng-zorro-antd/message";
import {Router} from "@angular/router";
import {UserActionService} from "@core/service/UserActionService";
import {AuthService} from "@core/service/AuthService";
import {NzContextMenuService} from "ng-zorro-antd/dropdown";
import {NzModalService} from "ng-zorro-antd/modal";
import {FileUploadService} from "@core/service/FileUploadService";
import {NzImageService} from "ng-zorro-antd/image";
import {ClipboardService} from "@core/service/ClipboardService";

@Injectable({
  providedIn: 'root',
})
export class MyDiskPageService extends PageService {
  constructor(
    protected diskService: DiskService,
    protected userActionService: UserActionService,
    protected authService: AuthService,
    protected message: NzMessageService,
    protected router: Router,
    protected nzContextMenuService: NzContextMenuService,
    protected dialogService: NzModalService,
    protected fileUploadService: FileUploadService,
    protected nzImageService: NzImageService,
    protected clipboardService: ClipboardService
  ) {
    super(
      diskService, userActionService, message, router,
      nzContextMenuService, dialogService, fileUploadService,
      nzImageService, clipboardService);
    super.rootUrl = 'myDisk'
    this.pageStatus.owner = {
      userId: authService.getUserInfo()?.userId || '',
      username: authService.getUserInfo()?.username || '我的文件',
      self:true
    }
  }

  /**
   * 处理请求入口
   * @param url 不带参数
   * @param params
   */
  dealUrl(url: string, params: any) {
    super.dealUrl(url, params)
    let path = this.openUrl.substring(8)
    if (path || params.id) {
      this.load(path, params)
    } else {
      this.router.navigate(['/myDisk/' + this.authService.getUserInfo()?.userId])
    }
  }
}
